A trajectory similarity computation method based on GAT-based transformer and CNN model

Trajectory similarity computation is very important for trajectory data mining. It is applied into many trajectory mining tasks, including trajectory clustering, trajectory classification and trajectory search etc. So efficient trajectory similarity computation method is very useful for improving trajectory mining result. Nowadays many trajectory similarity computation methods have been proposed. But most of them can not be applied into long trajectories similarity calculation efficiently. So a new algorithm called TrajGAT is proposed. This algorithm can calculate similarity for long trajectories. It treats long trajectory as a long sequence. By doing so, long-term dependency of long trajectory is considered by this algorithm while computing similarity value. But, the spatial feature of long trajectories is not considered. As long trajectory can be presented in many different shapes, if two long trajectories are judged as similar trajectories, the outline shape of these two trajectories should be similar as well. To solve this problem, a new trajectory similarity computation method is proposed in this paper. This method not only takes the long-term dependence feature into consideration, but also considers the outline feature of long trajectory. The proposed method employs GAT-based transformer to extract long-term dependence feature from long trajectory. And it applies Convolutional Neural Network to extract outline feature.

method which is called TrajGAT.This algorithm treats long trajectory as long sequence and applies transformer to capture long-term dependence feature of long trajectory.
Even though TrajGAT algorithm is better than other algorithms in long trajectory similarity computation, it still needs to be improved further.TrajGAT algorithm tries to model a long trajectory by constructing a graph.Then the graph is input into a GAT-based Transformer.By using this GAT-based Transformer, a vector will be calculated for every trajectory.During the procedure, the area that contains location points of all the trajectories is separated into small regions.In this situation, if location points of two trajectories are very close, they will be put into same small region.As graph is constructed based on corresponding small regions, if most location points of two trajectories are put into same small regions, the vector of these two trajectories will be very similar.In this situation, these two trajectories can be judged as similar trajectories by TrajGAT algorithm.According to this, if two trajectories are very close to each other, they will be judged as similar trajectories by TrajGAT algorithm.But, as the outline of long trajectory can be different shapes, even though two trajectories are close to each other, they still can't be similar trajectories.Because outline shape of two trajectories may be different.For example, in Fig. 1, obviously, the overlapping location point number of trajectory a and b is greater than the overlapping part of trajectory a and c.So more location points contained in a and b will be put into same small regions.Based on TrajGAT algorithm, trajectory a and b are more similar than a and c.But, the truth is that trajectory a and c are more similar.We can find that, not only many location points of a and c are overlapped, but also the outline shape of trajectory a and c are very similar.The outline shapes of both a and c are very close to a circle.But trajectory b is a unidirectional trajectory.So, while we try to find similar trajectories for a specific trajectory, the outline shape should also be considered.
In this situation, a new trajectory similarity calculation algorithm is proposed.This algorithm adopts GATbased Transformer to extract long-term dependence feature from long trajectory.At the same time, to extract the outline feature of long trajectory, Convolutional Neural Network (CNN) is employed by the proposed algorithm.During the procedure, a matrix will be constructed for every long trajectory.Then CNN model is used to extract outline feature of long trajectory based on the corresponding matrix.Accordingly, the contribution of this paper is as below: 1 A new trajectory outline feature extraction method is proposed.This method is based on CNN model.By using this method, a vector that contains outline feature is generated for every trajectory. 2 A new trajectory similarity calculation algorithm is proposed.In this algorithm, not only the long-term dependence feature of long trajectory but also the outline feature of long trajectory are considered.
Rest of this paper is organized as follows.The proposed algorithm is described in section 2. Experimental results and discussion are presented in section 3. Section 4 concludes the contents of this paper and discusses future work related to trajectory similarity calculation.

Long-term dependence feature extraction
The proposed algorithm which is called TrajBOAL tries to construct a vector for each trajectory.Similarity value of two trajectories is calculated based on vectors.As location points of a long trajectory are interrelated, while constructing vector for every long trajectory, the long-term dependency should be considered.TrajGAT 32 algorithm is proposed for calculating similarity value for two long trajectories.Long-term dependence feature of long trajectory is fully considered by this algorithm.So, the long-term dependence extraction method described in TrajGAT algorithm will be adopted by the proposed algorithm.Four steps are contained in TrajGAT algorithm while constructing vector for trajectory.Firstly, a hierarchical structure is constructed by using PR quadtree 33 .Then, generate a graph for every long trajectory based on constructed PR quadtree.Thirdly, a graph-based transformer layer is used to generate an embedding for a trajectory.Finally, TrajGAT algorithm applies deep metric learning framework to optimize the model parameters.
In the first step of TrajGAT algorithm, PR quadtree is used to model the hierarchical spatial structure.During the procedure, the square area that contains all the trajectories will be separated into four square sub-areas.Then, the location point number contained in each area should be counted.If location point number contained in one sub-area exceeds a specific threshold, this sub-area should be separated into four square sub-areas further.This procedure will be continued, until the location point number of each area is no more than the defined threshold.The separation result is presented in (a) of Fig. 2.
While the separation process is finished, a PR quadtree can be constructed based on the separation result.The structure of PR quadtree is presented in (b) of Fig. 2. In this PR quadtree, every non-leaf node represents a square area, which is separated into four square sub-areas.And these four square sub-areas are represented by the four children of the non-leaf node.So, the root of this tree is corresponding to the square area that contains all the trajectories.After the PR quadtree is constructed, an embedding vector can be computed for every node of this PR quadtree.During the procedure, as PR quadtree can be treated as a graph, Node2Vec algorithm is employed to fulfil the embedding vector calculation task.Based on Node2Vec algorithm, every node of RP quadtree will get a vector.According to Fig. 2, location point A to J contained in the PR quadtree can be found in (a) directly.α , β , δ and γ are four areas.δ represents the whole square area that contains all the location points of trajectories.γ is corresponding to the green square area.The yellow square area is represented by β .Obviously, the right bottom corner of yellow square area is covered by an orange square area.This area is corresponding to α.
Then, an embedding vector should be constructed for every trajectory by using GAT-based transformer layer.Before that, a graph should be constructed for every trajectory.During the procedure, PR quadtree is used.Firstly, the square area that contains all the location points need to be found.Take the trajectory presented in (a) of Fig. 3 as an example.Location points A and E are contained in area α .Points B, C, D and area α are contained in area β .Points F, G are contained in area γ .Area β and γ are contained in area δ .So four areas are obtained from PR quadtree, which are α , β , δ and γ .All the location point and all the square areas described above will be treated as nodes of the graph.Secondly, an edge set should be constructed.Two kinds of edges will be added into graph.The first kind is cross layer edge.If two nodes belong to different layers of PR quadtree, they will be connected by this kind of edge.The second type of edges is inner layer edge.If two nodes belong to same layer of PR quadtree, they will be connected by this kind of edge.The constructed graph is presented in (b) of Fig. 3.
While the graph is constructed, every node of this graph will get a vector.Then these vectors are input into GAT-based transformer layer.Vector of the i − th node is calculated as follows.
v i represents vector of the i − th node.Vector i represents the position encoding of the i − th node.Vector f i represents feature of the i − th node.
(1)  www.nature.com/scientificreports/Before calculating vector v i for the i − th node, feature vector f i of the i − th node should be computed.Vec- tor f i is calculated by concatenating three different vectors, which are f l i , f r i and f h i .f l i represents the coordinate feature vector of node i; f r i represents the region feature vector of node i; And f h i represents the hierarchical structure feature vector of node i. Calculation method of region feature vector f l i is as follows.
If node i is a location point, lat i and lon i represent the latitude value and longitude value of this point.If node i is a square area, lat i and lon i represent the latitude value and longitude value of center point of this square area.Function Normalize(.) represents min-max normalization method.Function MLP(.) represents Multi-layer Perceptron.Calculation method of region feature vector f r i is as follows.
If node i is a location point, w i and h i are set to 0. If node i is a square area, w i and h i are set to the edge length value of corresponding square area.Hierarchical structure feature vector f h of each node can be obtained based on PR quadtree.As every node of PR quadtree has been assigned a vector by using Node2Vec algorithm, hierarchical structure feature vector of all the nodes can be obtained easily.For square areas α , β , γ and δ , vector calculated based on Node2Vec algorithm will be treated as hierarchical structure feature vector directly.For all the location points, firstly, the leaf nodes of PR quadtree that contains them should be discovered.Then the vectors of these leaf nodes calculated by using Node2Vec algorithm need to be assigned to the corresponding location points as hierarchical feature vector.While every node getting a hierarchical structure feature vector, a special key should be added into these vectors.This special key is used to represent the hierarchical feature of all the nodes contained in PR quadtree.In this situation, the nodes that are close in space will share same special key.To obtain vector f i presented in Eq. (1), vector f l i , f r i and f h i will be concatenated.The procedure is as follows.
To obtain vector v i presented in Eq. (1), a vector named i should also be calculated.It is a position encoding vector.The vector calculation procedure is executed based on the graph T g presented in (b) of Fig. 3. Vector should be calculated for every node of graph T g by concatenating vector s and vector g .Vector s i contains position information.Vector g i contains connection relationship of the nodes contained in graph T g .While calculating vector s i , sequential information of graph T g need to be modeled.During the modeling procedure, a queue L is constructed.The nodes contained in graph T g are input into queue L in order, from the first layer to the last layer.Structure of queue L is presented in Fig. 4.
Then dequeue operation is performed.While node i is obtained after performing dequeue operation, a vector s i should be constructed for this node.And this newly constructed vector is treated as the i − th row of a matrix.While queue L becomes empty, a matrix is constructed.Each row of this matrix is corresponding to a specific node of graph T g .The column number of this matrix is d/2.Sinusoidal value calculation method 34 is used to calculate element values of vector s i .Element value calculation method is as below.
where ij represents element value in row i and column j of the matrix.The value of row index i is contained in set [1, ..., M].M is the number of nodes contained in graph T g .As the length of vector . s i is the i − th row of the matrix.To model connection relationship of nodes, Laplacian position encoding 35 is used.The method is presented below.
where A is adjacency matrix.D is degree matrix.contains all the eigenvalues.And U contains all the eigenvectors.top p (.) is an operation that slices the vectors corresponding to the p smallest non-trivial eigenvalues.g i is the Laplacian positional encoding result of node i.The length of vector g i is also d 2 .Now vector s i and g i should be concatenated to form position encoding vector of node i.The procedure is as below.
Then the feature vector f i and the position encoding vector i can be summed up to get vector v i , which is pre- sented in Eq. (1).Vector v i contains the feature of node i.
(2) x i , y i = Normalize(lat i , lon i ) www.nature.com/scientificreports/After all the nodes of the constructed graph got a vector v, GAT-based transformer should be used to calculate a vector for the trajectory, which is corresponding to the graph.During the procedure, vectors of all the nodes are input into GAT-based transformer one by one.If the graph of a trajectory contains M nodes, output of GATbased transformer will be a vector list, which is {h P 1 , h P 2 , ..., h P M } .Each vector h P is corresponding to a specific node of the graph.The embedding vector e of the trajectory is computed based on these vectors.Computation method is as below.As, while calculating vector h P i , vector v i is input into GAT-based transformer model at first, vector v i will be regarded as h 0 i .It is input into the first layer of GAT-based transformer model.The GAT-based transformer model contains P layers.Computation procedure of every GAT-based transformer layer is as follows.
where N i is a set that contains all the neighborhoods of the i − th node.

Outline feature extraction
Long trajectory contains many location points.If these location points are connected based on the order of timestamps, the outline of long trajectory can be presented.We can find that the outline shape of long trajectory is very complicated.So, while calculating similarity value, the outline feature of long trajectory should be extracted.To fulfil the task, Convolutional Neural Network (CNN) is used.During the outline feature extraction procedure, two steps will be executed.In the first step, a matrix is constructed for every trajectory.In the second step, these matrices are input into CNN model one by one.Then a vector can be generated for every trajectory by CNN model.This vector contains outline information of the corresponding trajectory.
While constructing matrix for a long trajectory, Mercator projection method 36 is used.Based on this method, geometric coordinate of a location point can be projected to Cartesian coordinate.While the projection task  www.nature.com/scientificreports/ is fulfilled, two steps should be performed.Firstly, the square area that contains all the trajectories needs to be separated into rows and columns.During the procedure, the most important task is to identify the square area.
To fulfil the task, latitude value and longitude value of all the location points will be collected.The minimum value and maximum value of latitude values and longitude values are extracted for setting the edges of the square area.Then the area between top and bottom horizontal edges are equally divided into W parts.The area between left and right vertical edges are equally divided into H parts.An example of square area division is presented in Fig. 5.As each row of the square area contains H grids and each column of the square area contains W grids, this square area can be treated as a W × H matrix. Element value of this matrix must be 1 or 0. Secondly, construct a W × H matrix for every trajectory.While constructing matrix m t for trajectory t, a row number and a column number should be computed for every location point of trajectory t.If the row number and column number of location point p are r and c, the element in the r − th row and c − th column of matrix m t will be set to 1. Obvi- ously, many elements of matrix m t are not related to location points of trajectory t.Value of these elements will be set to 0. When matrix construction is finished, the outline feature of every trajectory can be extracted based on the corresponding matrix.
The calculation method of row number and column number is presented below.
Suppose that the trajectory contains N different location points.Then latitude min = min 1≤n≤N latitude n , latitude max = max 1≤n≤N latitude n , longitude min = min 1≤n≤N longitude n .longitude max = max 1≤n≤N longitude n .⌈...⌉ is ceil operation.
After projecting every trajectory into matrix, CNN model can be used to extract outline feature for every trajectory based on corresponding matrix.The CNN model used in the proposed algorithm contains three convolutional layers, three max-pooling layers and a fully connected layer.The structure of CNN model is presented in Fig. 6.The filter size of different convolutional layer are 9 × 9 , 7 × 7 and 5 × 5 .The filter numbers of different convolutional layers are 32, 64 and 128.Output value of the fully connected layer is a vector which contains 10 elements.This output vector contains outline feature of a trajectory.
Initially, all the parameters of CNN model are generated randomly based on normal distribution.Autoencoder is used to optimize the parameters of the CNN model.The CNN model described above is treated as encoder of the auto-encoder neural network.The output vector of CNN model will be treated as input value of decoder part of auto-encoder neural network.The structure of decoder part is presented in Fig. 7.The decoder part of auto-encoder neural network contains a fully connected layer, three deconvolutional layer and three  Function norm(.)represents the normalization operation performed by using L-2 norm method.As matrix M o is obtained based on matrix M c , these two matrices should be as close as possible.Thus minimum value of this loss function should be obtained while optimizing the parameters of auto-encoder neural network.The backpropagation algorithm is employed to perform parameter updating procedure and Adam optimizer is used to fulfil optimization task.
The procedure of outline feature extraction is presented in algorithm 2. Input value this algorithm is a trajectory set.Output value of this algorithm is a vector set.

Trajectory similarity calculation
After long-term dependence feature and outline feature of trajectory are extracted, the embedding vector can be constructed for every trajectory.Based on the embedding vectors of all the trajectories, similarity value of any two trajectories can be calculated.
Suppose that vector which contains the long-term dependence feature of the i − th trajectory is v i and vector which contains the outline feature of the i − th trajectory is o i .The embedding vector e i of the i − th trajectory can be constructed as follows.where function concat(.)represents concatenation operation of two vectors.While every trajectory gets its own embedding vector, similarity value of any two trajectories can be calculated by using cosine similarity.Calculation method is as below.
where e i is embedding vector of the i − th trajectory, e j is embedding vector of the j − th trajectory.

Data description
In this experiment, two datasets are used.One is human mobility trajectory dataset which is called GeoLife dataset.The other is taxi trajectory dataset which is called Porto dataset.
GeoLife trajectory dataset consists of human mobility trajectories.These trajectories are created by 182 people over three years.Location point contained in every trajectory is described by four values, which are timestamp, Latitude, longitude and altitude.This dataset contains 17621 trajectories.And all the trajectories are collected by mobile devices.
Porto dataset consists of taxi trajectories.These taxi trajectories are created by 442 taxies, which are running in Porto, Portugal.These trajectories are also collected by using the mobile devices installed in the taxies.This dataset contains 1.7 million trajectories.
To extract long trajectories contained in these two datasets, location point number of every trajectory should be counted.If a trajectory contains more than 200 location points, it will be identified as a long trajectory.Otherwise, it will be identified as a short trajectory.

Comparison baseline
Three algorithms are selected to compare with the proposed algorithm.These algorithms are TrajGAT algorithm 32 , traj2vec algorithm 37 and Traj2SimVec algorithm 38 .Traj2vec algorithm is proposed for performing trajectory clustering.Before executing clustering, traj2vec algorithm is used to transform a trajectory into a vector.During the procedure, firstly, this algorithm uses a slide window to extract features from trajectory.Then a seq2seq auto-encoder method is used to build vector based on extracted features.By using these vectors, similarity value of all the trajectory pairs can be calculated.Traj2SimVec is also a vector construction algorithm.It generates triplet training samples based on training data.Then an encoder is used to map these triplet training samples into similarity space and matching space for getting sample representation vectors.TrajGAT algorithm is mainly proposed for constructing vector for long trajectory.This algorithm has been described in detail before.

Evaluation method
Currently, the best evaluation methods are self-similarity and cross-similarity comparison 22,39 .These methods try to evaluate the precision of the trajectory similarity computation algorithm based on the calculated k-nearest neighbors and real k-nearest neighbors.The procedure of these precision evaluation methods are presented in this section.
In this experiment, trajectory dataset is separated into two different sets.One is training set, the other is testing set.Training set is used for training model.Testing set is used for evaluating performance of the model.While executing trajectory similarity computation algorithms based on GeoLife dataset, the testing dataset contains 3000 trajectories.While executing algorithms based on Porto dataset, 10000 trajectories are selected to form testing dataset.
After testing set and training set are obtained, another dataset N s should be constructed based on testing set.During the construction procedure, m sub-trajectories are generated for every trajectory of testing set.All the sub-trajectories are added into set N s .While constructing a sub-trajectory for trajectory T, several non-adjacent location points of trajectory T should be randomly selected and dropped.Obviously, these m sub-trajectories will be treated as the real top-m most similar trajectories of trajectory T. When a trajectory similarity computation algorithm is running, it will select top-k most similar sub-trajectories for every trajectory of testing set from set N s .Based on k selected sub-trajectories and m generated sub-trajectories of all the trajectories contained in the testing set, evaluation value "HR@10", "HR@20" and "R10@20" can be obtained.During the procedure, the overlapping part of k selected sub-trajectories and m generated sub-trajectories is extracted.The proportion of overlapping trajectory number to value k should be calculated.This proportion value calculation procedure need to be executed for every trajectory of testing dataset.Finally, the average value of all the proportion values can be computed for every algorithm.Generally, the best algorithm must get the highest average value.If both variable m and variable k are equal to 10, evaluation value "HR@10" can be obtained from the experiment.If both variable m and variable k are equal to 20, evaluation value "HR@20" can be obtained.If variable m is equal to 20 and variable k is equal to 10, evaluation value "R10@20" can be obtained.

Trajectory similarity computation quality
In this section, the proposed trajectory similarity computation algorithm is compared with TrajGAT algorithm, traj2vec algorithm and Traj2SimVec algorithm.The experimental results are presented in two tables.Table 1 presents the experimental results obtained based on all the long trajectories of GeoLife dataset.Table 2 presents the experimental results obtained based on all the long trajectories of Porto dataset.In these two tables, TrajBOAL represents the proposed algorithm.Cosine similarity is employed to calculate similarity values.The evaluation metrics used in this experiment are "HR@10", "HR@50" and "R10@50".www.nature.com/scientificreports/From the experimental results, we can find that the proposed algorithm outperforms all the other comparison algorithms.As the proposed algorithm takes both long-term dependence feature and outline feature into consideration and TrajGAT algorithm only takes long-term dependence feature into consideration, it can be concluded that outline feature is important for distinguishing long trajectories.Thus, while calculating similarity value for two long trajectories, the outline feature must be considered.Moreover, it is obvious that TrajGAT algorithm outperforms Traj2SimVec algorithm and traj2vec algorithm.It proves that long-term dependence is also very important while calculating similarity value for long trajectory.

Trajectory clustering quality
As trajectory similarity computation method is often used in trajectory clustering algorithms, performance of a clustering algorithm using different similarity computation methods are compared in this experiment.The selected clustering algorithm is OPTICS.The similarity computation methods compared in this experiment are TrajGAT algorithm and the proposed algorithm.The clustering result evaluation methods used in this experiment are Rand Index and Compactness.The dataset used for testing clustering algorithm is Porto.The ground truth of clustering results is obtained by using the real similarity value of all the trajectory pairs.As, while the dense neighborhood space radius ǫ is set to different values, the performance of OPTICS algorithm keeps changing, the clustering algorithm will be tested under different ǫ value.In (a) and (b) of Fig. 8, the x-axis represents different ǫ value and the y-axis represents RI value or Compactness value of the clustering algorithm.
From experimental results presented in (a) and (b) of Fig. 8, we can find that almost all the points on the curve of the proposed algorithm are higher than the points on the curve of TrajGAT algorithm.It means that the clustering algorithm using proposed algorithm outperforms the clustering algorithm using TrajGAT algorithm in both RI value and compactness value.In this situation, we can conclude that the proposed algorithm outperforms TrajGAT algorithm as well.As OPTICS algorithm tries to find clusters based on distance among trajectories, the performance of this clustering algorithm is affected by these distance values.While performing clustering based on trajectory dataset, similarity value of two trajectories will be treated as distance of these two trajectories.So, if two trajectories are very similar, the distance between them will be judged as very close.In this situation, a well-performed trajectory similarity calculation method is very important for improving the

Trajectory similarity computation quality based on short trajectory set
Based on the experimental results presented above, we can find that the proposed algorithm is better than the compared algorithms while calculating similarity value for long trajectory.In this section, short trajectory dataset is used to test the proposed algorithm.The location point number of every short trajectory is less than 200.Three algorithms are compared with the proposed algorithm, which are Traj2vec, Traj2SimVec and TrajGAT.Three evaluation metrics are used which are "HR@10", "HR@20" and "R10@20".Short trajectories are extracted from Porto and Geolife dataset.Experimental results are presented in TableS 3 and 4.
Based on the experimental results, we can find that TrajGAT algorithm performs better than Traj2vec and Traj2SimVec algorithm.It proves that temporal dependence feature is also very important for distinguishing short trajectories.And, at the same time, we can find that the proposed algorithm performs better than TrajGAT algorithm, but "HR@10" value, "HR@20" value and "R10@20" value of these two algorithm are very close.It means that outline feature is not very important for distinguishing short trajectories.This is because, if the trajectory is short, the outline feature may be relatively simple.So the outline feature of many trajectories are very similar.But the proposed algorithm is still better than TrajGAT algorithm.So we can conclude that outline features of some trajectories is totally different from others.

Influence of embedding dimension
The output vector of CNN model contains outline feature of trajectory.If the output vector is too short, outline feature may be not described clearly by this vector.Thus, to select a suitable length for the output vector, algorithm performance based on different vector length should be tested.In this experiment, the length of output vector will be set to 4, 6, 8, 10, 12, 14. "HR@10" and "HR@20" are used to evaluate the proposed algorithm.Long trajectory set extracted from both Porto dataset and Geolife dataset are used in this experiment.The experimental results are presented in Fig. 9.
Based on the experimental results presented in (a) and (b) of Fig. 9, we can find that, while the length of output vector is less than 10, "HR@10" value and "HR@20" value of the proposed algorithm keep increasing.But, when the length of output vector is greater than 10, the variation of "HR@10" and "HR@20" is small.It means that, if the length of output vector is 10, the outline feature of trajectory can be fully reflected by the output vector.So, while length of output vector is greater than 10, performance of the proposed algorithm remains stable.In this situation, the output vector length of CNN model is set to 10.

Influence of grid size
When the proposed algorithm tries to extract outline feature from a trajectory, this trajectory should be projected to a W × W matrix. Value W is a parameter that is decided by users.To select the best W, different values should be tested.In this experiment, evaluation metrics "HR@10" and "HR@20" are used to find the best value for parameter W. Results of this experiment are presented in Fig. 10.The x-axis presents the different values that are assigned to parameter W. The y-axis presents the values of "HR@10" and "HR@20".
From the experimental results, we can find that, when parameter W is set to 50, "HR@10" and "HR@20" of the proposed algorithm reach the highest value.It means that the best value of parameter W is 50.If parameter W is too small, resolution ratio of the matrix constructed for every trajectory is bad.So the outline feature can't be extracted from the matrix precisely.In this situation, performance of the proposed algorithm will be affected.Similarly, if W is too large, sparse matrix will be constructed for every trajectory.In this situation, the outline feature of trajectory is distorted.Then, performance of the proposed algorithm will be affected as well.

Conclusions
Trajectory similarity calculation algorithms are widely used in many kinds of trajectory mining algorithms.
It is an important component of trajectory data mining.Nowadays, many trajectory similarity computation algorithms are proposed.But, all these methods don't take the outline feature of long trajectories into consideration.So, in this paper, a new trajectory similarity calculation algorithm is proposed.This algorithm takes both long-term dependence feature of long trajectory and outline feature of long trajectory into consideration.Thus, GAT-based transformer and CNN model are employed by the proposed algorithm.From experimental results, we can find that the proposed algorithm can cope with long trajectory similarity computation task efficiently.A trajectory is generated by a person who drives a vehicle.Thus the generated trajectory may be affected by the emotion, intention or personal habits of the drivers.In this situation, if all the personal factors are considered while calculating similarity value for trajectories, the performance of similarity calculation algorithm will be improved efficiently.So, in the future, we will try to develop new trajectory similarity computation methods in which the personal factors are considered.

Figure 1 .
Figure 1.Comparison of trajectory a, trajectory b and trajectory c.

Figure 3 .
Figure 3. Constructing graph for a trajectory based on PR quadtree.

Figure 5 .
Figure 5. Constructed grids based square area which contains all the trajectories.

Figure 9 .
Figure 9. Vector length selection for the output vector of CNN model.

Figure 10 .
Figure 10.Value "HR@10" and "HR@20" of the proposed algorithm obtained based on different value W.
represents the number of attention heads, k ∈ [1, ..., H] .h l+1 i is input into a Feed Forward Network (FFN).Residual connections and batch normalization module are contained in FFN.To calculate the parameter values of GAT-based transformer model, deep metric learning framework is employed by TrajGAT algorithm.The procedure of long-term dependence feature extraction is presented in algorithm 1. Input value of this algorithm is a trajectory set.Output value is a vector set.

Table 1 .
Experimental Results based on long trajectories extracted from GeoLife Dataset.

Table 2 .
Experimental results based on long trajectories extracted from porto dataset.Clustering results obtained based on dataset Porto.performance of OPTICS algorithm.According to this, we can observe the performance of TrajGAT algorithm and the proposed algorithm based on clustering quality of clustering algorithm.

Table 3 .
Experimental results based on short trajectories extracted from GeoLife dataset.

Table 4 .
Experimental results based on short trajectories extracted from porto dataset.